{extend name="base/frame" /}
{block name="main"}
<style>
    .layui-anim-upbit{
        z-index: 9999!important;
    }
</style>
<script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="/ueditor/lang/zh-cn/zh-cn.js"></script>
<form class="layui-form" action="" id="form" method="post">
    <input type="hidden" id="gid" name="gid" value="{$info['gid']|default=''}">
    <input type="hidden" id="pic" name="pic" value="{$info['pic']|default=''}">
    <input type="hidden" id="thumb" name="thumb" value="{$info['thumb']|default=''}">
    <div class="layui-form-item">
        <label class="layui-form-label">商品名称</label>
        <div class="layui-input-inline">
            <input type="text" name="name" lay-verify="required" autocomplete="off"
                   class="layui-input" value="{$info['name']|default=''}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商品价格</label>
        <div class="layui-input-inline">
            <input type="text" name="price" lay-verify="required" autocomplete="off"
                   class="layui-input" value="{$info['price']|default=''}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-inline">
            <input type="text" name="sort" lay-verify="required" autocomplete="off"
                   class="layui-input" value="{$info['sort']|default='0'}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商品库存</label>
        <div class="layui-input-inline">
            <input type="text" name="cnumber" lay-verify="required" autocomplete="off"
                   class="layui-input" value="{$info['number']|default=''}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商品分类</label>
        <div class="layui-input-inline">
            <select id="cate_id" name="cate_id" lay-verify="required">
                <option value=""></option>
                {volist name='catelist' id='item'}
                <option value="{$item['id']}"  {eq name="info['cate_id']|default='0'" value="$item.id"}selected{/eq} {eq name="item['up_id']|default='0'" value="0"}disabled{/eq}>{$item['name']}</option>
                {/volist}
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">缩略图</label>
        <div class="layui-input-inline">
            <button type="button" class="layui-btn" id="thumb_btn">
                <i class="layui-icon">&#xe67c;</i>上传图片
            </button>
            <div id="thumb_pic" class="upload_pic">
                {notempty name="info.thumb"}
                <img src='{$resurl}{$info.thumb}?x-oss-process=image/resize,m_fill,h_40,w_40'/>
                {/notempty}
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">商品图片</label>
        <div class="layui-input-inline">
            <button type="button" class="layui-btn" id="upload_btn">
                <i class="layui-icon">&#xe67c;</i>上传图片
            </button>
            <div id="pic_pic" class="upload_pic">
                {notempty name="info.pic"}
                <img src='{$resurl}{$info.pic}?x-oss-process=image/resize,m_fill,h_40,w_40'/>
                {/notempty}
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">是否展示</label>
        <div class="layui-input-inline">
            <input type="radio" name="isshow" value="0" title="否" {eq name="info['isshow']|default='1'" value="0"
                   }checked{/eq}>
            <input type="radio" name="isshow" value="1" title="是" {eq name="info['isshow']|default='1'" value="1"
                   }checked{/eq}>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否首页推荐</label>
        <div class="layui-input-inline">
            <input type="radio" name="isshow_sy" value="0" title="否" {eq name="info['isshow_sy']|default='0'" value="0"
                   }checked{/eq}>
            <input type="radio" name="isshow_sy" value="1" title="是" {eq name="info['isshow_sy']|default='0'" value="1"
                   }checked{/eq}>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商品描述</label>
        <div class="layui-input-block">
            <script id="detail" name="detail" type="text/plain"  >{$info['detail']|default=''}</script>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="sumform">确定</button>
        </div>
    </div>
</form>


{/block}
{block name="script"}
<script>
    var resurl="{$resurl}";

    UE.getEditor('detail');
    layui.upload.render({
        elem: '#upload_btn'
        , url: '/admin/index/upload?dir=goods'
        , done: function (res) {
            var pic=res.result
            //上传成功
            if (res.error_code == 0) {
                $('#pic').val(pic);
                $("#pic_pic").html("<img src='" + resurl + pic + "?x-oss-process=image/resize,m_fill,h_40,w_40'/>")
            }
            if (res.error_code > 0) {
                return layer.msg('上传失败');
            }
        }
        , error: function () {

        }
    });
    layui.upload.render({
        elem: '#thumb_btn'
        , url: '/admin/index/upload?dir=goods'
        , done: function (res) {
            var pic=res.result
            if (res.error_code == 0) {
                $('#thumb').val(pic);
                $("#thumb_pic").html("<img src='" + resurl + pic + "?x-oss-process=image/resize,m_fill,h_40,w_40'/>")
            }
            if (res.error_code > 0) {
                return layer.msg('上传失败');
            }
        }
        , error: function () {

        }
    });
</script>
{/block}